s0 = "zero"
s1 = "one"
s2 = "two"
s3 = "three"
s4 = "four"
s5 = "five"
s6 = "six"
s7 = "seven"
s8 = "eight"
s9 = "nine"
sotn = 100
sl = [s0, s1, s2, s3, s4, s5, s6, s7, s8, s9]
#print(sl)
desat = 10
edin = 1
mi1 = 0
ma1 = 0
l = 0
l1 = 0
prov = 0
s10 = input().split()
if len(s10) == 3:
    if (s10[0] not in sl or s10[1] not in sl or s10[2] not in sl):
        prov = 1
a = []
for i in range(100, 1000):
    for y in range(2, i):
        if i % y == 0:
            break
    else:
        a.append(i)
#print(a)
per = a[0]
for i in range(len(s10)):

    if s10[i]==s0:
        if i == 0:
            sotn = sotn * 0
        elif i == 1:
            desat = desat * 0
        elif i == 2:
            edin = edin * 0

    
    if s10[i]==s1:
        if i == 0:
            sotn = sotn * 1
        elif i == 1:
            desat = desat * 1
        elif i == 2:
            edin = edin * 1

            
    if s10[i]==s2:
        if i == 0:
            sotn = sotn * 2
        elif i == 1:
            desat = desat * 2
        elif i == 2:
            edin = edin * 2
 

    if s10[i]==s3:
        if i == 0:
            sotn = sotn * 3
        elif i == 1:
            desat = desat * 3
        elif i == 2:
            edin = edin * 3

            
    if s10[i]==s4:
        if i == 0:
            sotn = sotn * 4
        elif i == 1:
            desat = desat * 4
        elif i == 2:
            edin = edin * 4

            
    if s10[i]==s5:
        if i == 0:
            sotn = sotn * 5
        elif i == 1:
            desat = desat * 5
        elif i == 2:
            edin = edin * 5
 
    if s10[i]==s6:
        if i == 0:
            sotn = sotn * 6
        elif i == 1:
            desat = desat * 6
        elif i == 2:
            edin = edin * 6

            
    if s10[i]==s7:
        if i == 0:
            sotn = sotn * 7
        elif i == 1:
            desat = desat * 7
        elif i == 2:
            edin = edin * 7

            
    if s10[i]==s8:
        if i == 0:
            sotn = sotn * 8
        elif i == 1:
            desat = desat * 8
        elif i == 2:
            edin = edin * 8

               
    if s10[i]==s9:
        if i == 0:
            sotn = sotn * 9
        elif i == 1:
            desat = desat * 9
        elif i == 2:
            edin = edin * 9
    l1 += 1
#print(l1)
n = sotn + desat + edin
#print(n)
if n == 100:
    print(per)
else:
    if n < 100 or len(s10) != 3 or prov == 1:
        print("Wrong input")
    else:
        for i in range(len(a)):
            if a[i] <= n:
                l = i
                mi1 = a[i]
            if a[i] >= n:
                ma1 = a[l + 1]
        #print(mi1, ma1)
        if abs(n-mi1) < abs(n-ma1) or abs(n-mi1) == abs(n-ma1):
            print(mi1)
        elif abs(n-ma1) < abs(n-mi1):
            print(ma1)
